home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
- Subject: Re: C coding problem
- Date: 3 Apr 1996 18:57:42 -0600
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4jv6q6$cpn@solutions.solon.com>
- References: <4ianbf$h86@solutions.solon.com> <4io1io$no4@solutions.solon.com> <4j41ru$nq4@solutions.solon.com> <4jttlq$3p1@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4jttlq$3p1@solutions.solon.com>,
- Niall Smart <nsmart@indigo.ie> wrote:
- >Michael Smith <msmith@mpx.com.au> wrote:
- >
- >>Konrad Schwarz wrote:
- >>>
- >>> I recently wrote a loop that went like this:
- >>>
- >>> while (p < end_p)
- >>> ++*p++;
- >>>
- >
- >>This is largely a matter of taste
- >
- >I would argue that it is far more than that.
- >
- >>, but personally I don't like that
- >>construct. A programmer less skilled than you might easily misunderstand
- >>that and introduce an error. I would prefer:
- >
- >>for ( ; p<end_p; p++)
- >> ++(*p);
- >
- >or either of:
- >
- >while (p < end_p)
- >{
- > (*p)++;
- > p++;
- >}
- >
- >while (p++ < end_p)
- >{
- > (*p)++;
- >}
- >
- >Zero chance for ambiguity in the last three versions.
-
- There is zero chance for ambiguity in any of the four. The evaluation order is
- well defined. I think what you mean is that there is less of a chance (though I
- would not say zero) that an inexperienced C programmer will find these three
- versions ambiguos.
- --
-